package com.aaa.methodreference.demo03;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.function.Supplier;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 实例方法的引用
 * @date 2022/11/4
 */
public class Test01 {
    public static void main(String[] args) {
        //无参，返回学生对象的名称
        Student stu = new Student("李四","22");

        //观察该Lambda表达式：对象名.实例方法();
        //Supplier<String> supplier=()->stu.getAge();

        //方法引用
        // 实例方法的引用   inst::instMethod    (args)->inst.instMethod(args)
        Supplier<String> supplier1=stu::getName;


        //System.out.println(supplier.get());
        System.out.println(supplier1.get());
    }
}

@Data
@NoArgsConstructor
@AllArgsConstructor
class Student{
    private String name;
    private String age;
}